x
permissionfree
watch 'command | othertool | yet-another-tool'
stty rows 50 cols 132
Reference: How to change the width of remote serial console? [duplicate]
The above solution may cause messed text in Vim. Maybe a better solution is resizable serial console window?.
progress
Toggle display of progress meter.
vncserver -fp catalogue:/etc/X11/fontpath.d
-fp catalogue:/etc/X11/fontpath.d
is required. No idea
of the reason.
It will prompts the password.
ssh -p 10001 user_name@host_ip -L 7000:master:5908
master
is the host name, 5908
is the port
which the VNC server listens to. 7000
is the port number on
the client side which ssh forwards to 5908
.
localhost:7000
.ssh user1@server1 date
ssh user1@server1 bash my.sh
/etc/ssh/sshd_config
to set
PasswordAuthentication no
.systemctl restart sshd.service
ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub
sftp -oBatchMode=no -b YOUR_COMMAND_FILE_PATH USER@HOST
If it requires the password, use sshpass
to pass the
password.
sshpass -p YOUR_PASSWORD sftp -oBatchMode=no -b YOUR_COMMAND_FILE_PATH USER@HOST
Use -o
, which means “or”:
find Documents \( -name "*.py" -o -name "*.html" \)
7z -v100m a my_zip.7z my_folder/
$ paste f1 f2 | tr -d '\t'
123456789abcdefghij
9876543211111111111
0000000003333333333
find . -type f
ls | grep -v '\.jar$'
fbase=PressureContour_SliceCore_REF_G1R2P1It
for f_fullname in ${fbase}[0-9]*; do
fname=${f_fullname%.*}
mv "$f_fullname" $(printf "${fbase}%05d.png" "${fname#${fbase}}")
done
Run the following file as transpose.sh file_name
awk '
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
for(j=1; j<=p; j++) {
str=a[1,j]
for(i=2; i<=NR; i++){
str=str" "a[i,j];
}
print str
}
}' $1
To change all the directories to 755 (drwxr-xr-x)
:
find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
To change all the files to 644 (-rw-r--r--)
:
find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
x
permissionTo view the files in a directory, the directory must have a
x
permission.
grep -rwnil abc | while read f; do sed -i 's/abc/ref/gI' $f; done
Use unzip -O cp936 file.zip
For example, to find all files in the current directory that have been modified since yesterday (24 hours ago) use:
find . -maxdepth 1 -mtime -1
Note that to find files modified before 24 hours ago, you have to use
-mtime +1
instead of -mtime -1
.
free
❯ free -m
total used free shared buff/cache available
Mem: 191891 22150 1698 4171 168042 164146
Swap: 0 0 0
available
includes free
and a part of
buff/cache
.
If free
is close to 0
, do not worry. If the
following things happen, you must check what is going on.
available
memory is close to zeroswap
used increases or fluctuatesdmesg | grep oom-killer
shows the OutOfMemory-killer at
workyum autoremove [package_name]
repoquery --installed -l httpd
systemctl stop [servicename]
systemctl disable [servicename]
rm /etc/systemd/system/[servicename]
rm /etc/systemd/system/[servicename] # and symlinks that might be related
rm /usr/lib/systemd/system/[servicename]
rm /usr/lib/systemd/system/[servicename] # and symlinks that might be related
systemctl daemon-reload
systemctl reset-failed
You can get this information from /proc
filesystem, it
stores information about running processes.
cat /proc/<pid>/environ
cd /proc/<pid>/cwd; pwd -P
cat /proc/<pid>/cmdline
Another method is
lsof -p $PID
The parameter of lstart
of ps
does this
job.
ps -eo pid,lstart,cmd
ps aux | grep nfs_opt | awk '{print $2}' | while read i; do kill -9 $i; done
The stat
of the zombie process is Z
.
ps aux | grep 'Z'
You have to kill the parent process of the zombie process.
$ pstree -p -s ${zombie_pid}
init(1)---cnid_metad(1311)---cnid_dbd(5145)
$ kill 5145 # Usually kill the 1st one
The following specfies the width of the column user
to
be 16
. The key is to use the option o
or
-o
.
alias ps_mod='ps ax o user:16,pid,pcpu,pmem,vsz,rss,stat,start_time,time,cmd'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${RED}The CPU usage(2nd column) and memory usage(3rd column) of the currently login users are as follows,${NC}"
own=$(id -nu)
cpus=$(lscpu | grep "^CPU(s):" | awk '{print $2}')
normal_users=$(cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1)
# Assume that the length of username is less than 20
proc_users=$(ps ax o user:20 | awk '{print $1}' | sort -u)
proc_normal_users=''
for pu in $proc_users; do
for nu in $normal_users; do
if [[ $pu == $nu ]]; then
proc_normal_users=$proc_normal_users$pu" "
fi
done
done
# for user in $(who | awk '{print $1}' | sort -u)
for user in $proc_normal_users
do
# print other user's CPU usage in parallel but skip own one because
# spawning many processes will increase our CPU usage significantly
if [ "$user" = "$own" ]; then continue; fi
(top -b -n 1 -u "$user" | awk -v user=$user -v CPUS=$cpus 'NR>7 { sum += $9; } END { print user, sum, sum/CPUS; }') &
# don't spawn too many processes in parallel
sleep 0.05
done
wait
# print own CPU usage after all spawned processes completed
top -b -n 1 -u "$own" | awk -v user=$own -v CPUS=$cpus 'NR>7 { sum += $9; } END { print user, sum, sum/CPUS; }'
echo -e "${BLUE}In the 2nd column, 100 means 1 CPU is being used.${NC}"
echo -e "${RED}If someone is using this node, try other nodes please!${NC}"
PSR
number shows the processor number the process is
assigned to.
Thus use ps -aF
or ps -q 7810 -o psr
.
sudo nethogs wlan0
ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4
To stack more than 2 videos, you can simply specify
hstack=inputs=3
.
ffmpeg -f concat -safe 0 -i <(for f in ./*.ogv; do echo "file '$PWD/$f'"; done) -c copy output.ogv
Reference: ffmpeg concat demuxer
convert
convert -delay 25 -loop 0 -quality 100 Pressure*.png Pressure.mp4
Note: The video file by convert
can be played by video
player but not by Chrome.
ffmpeg
By pipe
cat PressureContour_SliceCore_REF_G1R2P1It0*.png | ~/Softwares/ffmpeg/ffmpeg -f image2pipe -framerate 4 -i - -c:v libx264 -pix_fmt yuv420p out.mp4
Another method is sequential reading. However, it requires that the
index of the image should be starting from 1. If not, you need to
specify the -start_number 50
. But the second index number
should be 51
. That is bad design.
The above ffmpeg method produce a video file which is played
perfectly in Chrome but in apps like PotPlayer it shows wrongs frames at
the end of the video file. For example, ffmpeg says this video is
9.23s
. PotPlayer says this video is 10s
and
shows wrong frames after 9.23s
.
Reference: ffmpeg wiki: Create a video slideshow from images
Another problem is that h264 codec requires even dimensions.
ffmpeg -r 24 -i frame_%05d.jpg -vcodec libx264 -y -an video.mp4 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2"
Reference: FFMPEG (libx264) “height not divisible by 2”
Use ffmpeg
to convert. Use convert
from
imagemagick
to reduce size.
ffmpeg -i input.mp4 -pix_fmt rgb24 input_raw.gif
convert -loop 0 -layers Optimize input_raw.gif input.gif
Try using -gravity North
(this will move your text to
the top of the image) and then adding an offset
(-annotate +0+100
) to move down your text:
convert temp.jpg -gravity North -pointsize 30 -annotate +0+100 'Love you mom' temp1.jpg
Use pdfcrop
Use pdfinfo
pdfinfo -box input_file.pdf
Use Ghostscript. Shell script is as follows,
#!/bin/bash
input_fname=$1
left=$2
bottom=$3
right=$4
top=$5
if [ "$top" == "" ]; then
echo "Usage: ./crop_pdf.sh input_file.pdf left bottom right top"
else
extension="${input_fname##*.}"
filename="${input_fname%.*}"
output_fname="${filename}_crop.pdf"
# Use pdfinfo -box input_file.pdf to get the box info of this pdf.
gs -sDEVICE=pdfwrite -sOutputFile=$output_fname -dBATCH -dNOPAUSE -c "[ /CropBox [ $left $bottom $right $top ] /PAGES pdfmark" -f $input_fname
fi
Use pdfjam
which is installed by tlmgr
in
the TexLive distro. The usage is as
follows,
pdfjam input_location_discontinuous_crop.pdf input_location_merged_crop.pdf --nup 2x1 --outfile input_location.pdf
$ scontrol show job 1665191
JobId=1665191 Name=tasktest
...
Shared=OK Contiguous=0 Licenses=(null) Network=(null)
Command=/lustre/work/.../slurm_test/task.submit
WorkDir=/lustre/work/.../slurm_test